Make BablMutex recursive on all platforms.
authorNils Philippsen <nils@redhat.com>
Fri, 13 Feb 2015 12:24:52 +0000 (13:24 +0100)
committerNils Philippsen <nils@redhat.com>
Fri, 13 Feb 2015 12:55:24 +0000 (13:55 +0100)
Win32 Critical Sections are recursive locks, initialize pthread mutexes
as recursive as well.

babl.pc.in
babl/Makefile.am
babl/babl-mutex.c
configure.ac
extensions/Makefile.am
tests/Makefile.am
tools/Makefile.am

index 76b5e69fadc60e514a0024303028a59d4628f04f..3f2049fc76bb575df85ba3023909c25af32f3221 100644 (file)
@@ -7,4 +7,5 @@ Name: babl
 Description: Dynamic, any to any, pixel format conversion library
 Version: @BABL_REAL_VERSION@
 Cflags: -I${includedir}/@PACKAGE_NAME@-@BABL_API_VERSION@
-Libs: -L${libdir} -l@PACKAGE_NAME@-@BABL_API_VERSION@ @MATH_LIB@
+Libs: -L${libdir} -l@PACKAGE_NAME@-@BABL_API_VERSION@
+Libs.private: @MATH_LIB@ @THREAD_LIB@
index 4f59447c3da7fd5ed10579fa78684b1f1a4858d5..6827faa1381b049c0bb4fce894d5c6c82f5ab8a3 100644 (file)
@@ -86,7 +86,7 @@ libbabl_@BABL_API_VERSION@_la_LIBADD=\
        @LTLIBOBJS@
 
 libbabl_@BABL_API_VERSION@_la_LDFLAGS=                 \
-       ${no_undefined} $(MATH_LIB)     \
+       ${no_undefined} $(MATH_LIB) $(THREAD_LIB) \
        -version-info $(BABL_LIBRARY_VERSION)
 
 EXTRA_DIST = babl-ref-pixels.inc
index 3f82cc526ae7241ccbbc9ea0740db1d6e1ddbf47..eacd37222230b051b22794086deaff765a4c45e0 100644 (file)
@@ -30,7 +30,12 @@ babl_mutex_new (void)
 #ifdef _WIN32
   InitializeCriticalSection (mutex);
 #else
-  pthread_mutex_init (mutex, NULL);
+  pthread_mutexattr_t mutexattr;
+
+  pthread_mutexattr_init (&mutexattr);
+  pthread_mutexattr_settype (&mutexattr, PTHREAD_MUTEX_RECURSIVE);
+  pthread_mutex_init (mutex, &mutexattr);
+  pthread_mutexattr_destroy (&mutexattr);
 #endif
   return mutex;
 }
index cffdbfc189f410561674747c37f0276eede1ff5f..5e60760730dcd3daece580541a767477a930b46d 100644 (file)
@@ -254,6 +254,7 @@ AC_MSG_RESULT([$platform_win32])
 AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
 
 MATH_LIB=-lm
+THREAD_LIB=-lpthread
 AC_MSG_CHECKING([for native Win32])
 case "$target_or_host" in
   *-*-mingw*)
@@ -261,6 +262,7 @@ case "$target_or_host" in
     PATH_SEP=';'
     DIR_SEP='\\'
     MATH_LIB=
+    THREAD_LIB=
     ;;
   *)
     os_win32=no
@@ -272,6 +274,7 @@ AC_MSG_RESULT([$os_win32])
 AC_SUBST(PATH_SEP)
 AC_SUBST(DIR_SEP)
 AC_SUBST(MATH_LIB)
+AC_SUBST(THREAD_LIB)
 
 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
 AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")
index 395473978476088a45afedf73de196ff35416a37..4a3fb8a343b553b72471ef754de69d3edcb6b5b7 100644 (file)
@@ -53,7 +53,8 @@ ycbcr_la_SOURCES = ycbcr.c
 float_la_SOURCES = float.c
 fast_float_la_SOURCES = fast-float.c
 
-LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la $(MATH_LIB)
+LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la $(MATH_LIB) \
+       $(THREAD_LIB)
 
 sse2_float_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
 sse2_int8_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
index 2733a28c4a33d308ae400ea4a7fbf8968b7cb069..6e282af51a113fba0aaf7ff42887314bee7ce1ae 100644 (file)
@@ -35,7 +35,7 @@ AM_LDFLAGS  = -pthread
 endif
 
 LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
-       $(MATH_LIB)
+       $(MATH_LIB) $(THREAD_LIB)
 
 EXTRA_DIST=common.inc
 
index f67a66e6b8045bebb33ac714df8ee1e1392fb8ba..ad544558dc3efed4f6adc02e99fd5c27e875c036 100644 (file)
@@ -1,9 +1,9 @@
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
 
 LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
-       $(MATH_LIB)
+       $(MATH_LIB) $(THREAD_LIB)
 
 if HAVE_SRANDOM
 noinst_PROGRAMS =              \
        babl-gen-test-pixels
-endif
\ No newline at end of file
+endif